<template>
  <div>
    <div class="user-header">
      <div class="user-header-info">
        <div class="user-header-info-name">
          <p class="user-header-info-name-l">
            {{ projectData ? projectData.name : '--' }}
            <em>进行中</em>
          </p>
        </div>
        <p class="user-header-info-address">
          <span class="name-title">
            项目所在地
          </span>
          <span class="name-value">
             {{
              projectData ? `${projectData.province}${projectData.city}${projectData.district}${projectData.address}` : '--'
            }}
          </span>
        </p>
        <div class="user-header-info-call">
          <div class="user-header-info-call-p">
            <p><span class="name-title">负责人</span>{{userData?userData.nickName:''}}</p>
            <p><span class="name-title">负责人电话</span>{{userData?userData.phonenumber:''}}</p>
          </div>
          <div class="user-header-info-call-r">
            <p class="user-header-info-call-r-title">执勤点数</p>
            <div class="user-header-info-call-r-work">
              <p>{{total}}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="user-table">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="基本信息" name="info"></el-tab-pane>
        <el-tab-pane label="执勤点" name="point"></el-tab-pane>
        <el-tab-pane label="合同" name="contract"></el-tab-pane>
<!--        <el-tab-pane label="发票" name="invoice"></el-tab-pane>-->
      </el-tabs>
      <component :is="activeName" :paramId="paramId" :projectData="projectData" @getPointFn="getDetail" type="projectDetail" :contractId="contractId"/>
    </div>
  </div>
</template>

<script>
import info from "./components/info";
import contract from "./components/contract";
import invoice from "./components/invoice";
import point from "./components/point";
import {listStagnationPoint} from "@/api/system/stagnation_point";
import {
  getProject
} from "@/api/system/project";


export default {
  name: "detail",
  components: {
    info,
    contract,
    invoice,
    point
  },
  data() {
    return {
      activeName: 'info',
      paramId: 0,
      projectData: null,
      total: 0,
      userData: null,
      contractId: 0
    };
  },
  created() {
    this.paramId = this.$route.params && this.$route.params.projectId;
    this.getDetail()
    this.getPostList()
  },
  methods: {
    getDetail() {
      getProject(this.paramId).then(response => {
        this.contractId = response.data.contract?response.data.contract.id: 0
        this.userData = response.data.user
        this.projectData = response.data.detail
      });
    },
    handleClick(tab, event) {
      console.log(tab, event);
    },
    getPostList() {
      this.loading = true;
      listStagnationPoint({
        pageNum: 1,
        pageSize: 50,
        projectId: this.paramId
      }).then(response => {
        this.total = response.total;
      });
    },
  }
}
</script>

<style scoped>
.user-header {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 10px;
}

.user-header {
  display: flex;
}

.user-header-img {
  margin-right: 40px;
}

.user-header-img img {
  width: 186px;
}

.user-header-info {
  flex: 1;
}

.user-header-info p {
  margin: 0;
}

.user-header-info-name {
  font-size: 18px;
  font-weight: 500;
  display: flex;
  margin-bottom: 10px !important;
  align-items: center;
}

.user-header-info-name-l {
  flex: 1;
  display: flex;
}

.user-header-info-name em {
  font-size: 12px;
  background: green;
  color: #fff;
  font-style: normal;
  margin-left: 10px;
  height: 22px;
  line-height: 22px;
  width: 50px;
  text-align: center;
  display: block;
  border-radius: 11px;
}

.user-header-info-address {
  font-size: 12px;
}

.user-header-info-address span {
  color: rgba(0, 0, 0, .3);
}

.user-header-info-address em {
  color: #ffba00;
  font-style: normal;
}

.user-header-info-address .name-value {
  color: #000;
}

.name-title {
  margin-right: 20px;
}

.user-header-info-call {
  margin-top: 10px;
  border-top: 1px dashed #f4f4f4;
  width: 100%;
  padding-top: 20px;
  display: flex;
  font-size: 12px;
}

.user-header-info-call-p {
  flex: 1;
  border-right: 1px solid #f4f4f4;
}

.user-header-info-call-p p {
  margin-bottom: 10px;
}

.user-header-info-call-p span {
  color: rgba(0, 0, 0, .3);
}

.user-header-info-call-r {
  width: 130px;
  border-right: 1px solid #f4f4f4;
  padding: 0 20px;
}

.user-header-info-call-r-title {
  margin-bottom: 10px !important;
  color: rgba(0, 0, 0, .3);
}

.user-header-info-call-r-work {
  font-size: 14px;
}

.user-table {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
}

.user-btn-status {
  border: 1px solid #ddd;
  font-size: 12px;
  display: flex;
  align-items: center;
  border-radius: 15px;
  overflow: hidden;
}

.user-btn-status span {
  cursor: pointer;
  padding: 0 20px;
  height: 30px;
  display: block;
  line-height: 30px;
}

.user-btn-status span:first-child {
  border-right: 1px solid #ddd;
}

.user-btn-status span:hover {
  background: #f8f8f8;
}
</style>
